﻿using System;
using System.Windows.Forms;

namespace NuSoft.SistemaGestionPersonal.WinFormsUI
{
    public partial class EmployeesFilterForm : Form
    {
        public int? EmployeeId { get { return !string.IsNullOrEmpty(EmployeeIdTextBox.Text) ? int.Parse(EmployeeIdTextBox.Text) : (int?)null; } }
        public string EmployeeName { get { return NameTextBox.Text; } }
        public string EmployeeLastName { get { return LastNameTextBox.Text; } }

        public EmployeesFilterForm()
        {
            InitializeComponent();
        }

        private void FilterButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Hide();
        }

        private void CancelFilterButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Hide();
        }

        private void EmployeeIdTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = !char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar);
        }

        private void NameTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = !char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar);
        }

        private void LastNameTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = !char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar);
        }
    }
}